package com.book.controller;

import com.book.model.dto.FeedBackQueryDTO;
import com.book.model.entity.Feedback;
import com.book.service.FeedbackService;
import com.book.util.BaseResult;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 问题反馈表 前端控制器
 * </p>
 *
 * @author auto
 * @since 2025-04-02 06:38:55
 */
@RestController
@RequestMapping("/feedback")
@Tag(name = "反馈", description = "反馈相关接口")
public class FeedbackController {

    @Autowired
    private FeedbackService feedbackService;


    @GetMapping("/list")
    @ApiOperation(value = "反馈列表-所有", notes = "反馈列表")
    public BaseResult<?> getFeedbackAllList() {
        return BaseResult.successResult(feedbackService.getFeedbackList());
    }

    @GetMapping("/listById/{id}")
    @ApiOperation(value = "获取用户反馈内容", notes = "获取用户反馈内容")
    public BaseResult<?> getFeedbackListById(@PathVariable("id") String id) {
        return BaseResult.successResult(feedbackService.getFeedbackListById(id));
    }

    @PostMapping("/listByParam")
    @ApiOperation(value = "获取反馈内容", notes = "获取反馈内容")
    public BaseResult<?> getFeedbackListByParam(@RequestBody FeedBackQueryDTO dto) {
        return BaseResult.successResult(feedbackService.getFeedbackListByParam(dto));
    }

    @GetMapping("/listByPage/{id}")
    @ApiOperation(value = "获取用户反馈内容", notes = "获取用户反馈内容")
    public BaseResult<?> getFeedbackListByPage(@PathVariable("id") String id) {
        return BaseResult.successResult(feedbackService.getFeedbackListById(id));
    }

    @DeleteMapping("/{id}")
    @ApiOperation(value = "获取用户反馈内容", notes = "获取用户反馈内容")
    public BaseResult<?> deleteFeedback(@PathVariable("id") String id) {
        return BaseResult.successResult(feedbackService.removeById(id));
    }

    @PostMapping("/add")
    @ApiOperation(value = "添加反馈", notes = "添加反馈")
    public BaseResult<?> addFeedback(@RequestBody Feedback feedback) {
        return BaseResult.successResult(feedbackService.addFeedBack(feedback));
    }

    @PostMapping("/deal")
    @ApiOperation(value = "处理反馈", notes = "处理反馈")
    public BaseResult<?> dealFeedback(@RequestBody Feedback feedback) {
        return BaseResult.successResult(feedbackService.dealFeedBack(feedback));
    }


}
